#ifndef GARLIC_EXPRESSION_HELPER_H
#define GARLIC_EXPRESSION_HELPER_H

#include "decompiler/structure.h"
#include "jvm/jvm_ins_helper.h"

/**
 * eg:
 * static inline bool
 * exp_is_unknow(jd_exp *e)
 * {
 *      return e->type == JD_EXPRESSION_UNKNOWN;
 * }
 **/

#define DEFINE_EXP_HELPER_METHOD(opcode, code_name) \
    static inline bool                              \
    exp_is_##code_name(jd_exp *e)                   \
    {                                               \
        return e->type == opcode;                   \
    }

DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_UNKNOWN,             unknown);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_EMPTY,               empty);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_DEFINE_STACK_VAR,    define_stack_var);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_STACK_VALUE,         stack_value);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_STACK_VAR,           stack_var);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_LVALUE,              lvalue);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_ARRAYLENGTH,         arraylength);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_LITERAL,             literal);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_OPERATOR,            operator);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_SINGLE_OPERATOR,     single_operator);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_SINGLE_LIST,         single_list);

DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_COMPARE,             compare);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_ASSIGNMENT,          assignment);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_INVOKE,              invoke);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_IF,                  if);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_SWITCH,              switch);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_NEW_ARRAY,           new_array);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_ARRAY_LOAD,          array_load);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_ARRAY_STORE,         array_store);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_NEW_OBJ,             new_object);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_CAST,                cast);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_ANNOTATION,          annotation);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_CONST,               const);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_GOTO,                goto);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_RETURN,              return);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_TERNARY,             ternary);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_GET_STATIC,          get_static);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_PUT_STATIC,          put_static);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_GET_FIELD,           get_field);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_PUT_FIELD,           put_field);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_IINC,                iinc);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_UNINITIALIZE,        uninitialize);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_INSTANCEOF,          instanceof);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_ATHROW,              athrow);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_SWAP,                swap);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_POP,                 pop);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_DUP,                 dup);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_LOCAL_VARIABLE,      local_variable);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_STORE,               store);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_INITIALIZE,          initialize);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_ASSIGNMENT_CHAIN,    assignment_chain);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_LABEL,               label);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_BREAK,               break);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_CONTINUE,            continue);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_LOGIC_NOT,           logic_not);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_WHILE,               while);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_DO_WHILE,            do_while);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_FOR,                 for);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_MONITOR_ENTER,       monitor_enter);
DEFINE_EXP_HELPER_METHOD(JD_EXPRESSION_MONITOR_EXIT,        monitor_exit);



#endif //GARLIC_EXPRESSION_HELPER_H
